<%@ page language="java"
	import="java.text.*,java.util.*,school.dao.StudentDao,school.entity.Student"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'doAddStudent.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

</head>

<body>
	<%
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

		request.setCharacterEncoding("UTF-8");
		String sname = request.getParameter("sname");
		String sex = request.getParameter("sex");
		String telephone = request.getParameter("telephone");
		String qq = request.getParameter("qq");
		String wechat = request.getParameter("wechat");
		Long gradeid = Long.parseLong(request.getParameter("gradeid"));
		Date enterdate = sdf.parse(request.getParameter("enterdate"));
		String fromcity = request.getParameter("fromcity");
		Date birthday = sdf.parse(request.getParameter("birthday"));
		String address = request.getParameter("address");
		String pass = request.getParameter("pass");
		Date last_exam = sdf.parse(request.getParameter("last_exam"));

		Student s = new Student(sname, telephone, sex, wechat, fromcity, pass, address, qq, gradeid, birthday,
				enterdate, last_exam);
		int i = StudentDao.DAO.addStudent(s);
		if(i==1){
		out.print("<script>alert('添加成功！')</script>");
		}else{
		out.print("<script>alert('添加失败！')</script>");
		}
	%>
</body>
</html>
